@@ -0,0 +1,23 @@ |
||
1 |
+# Generated by Django 3.2.6 on 2022-12-26 04:56 |
|
2 |
+ |
|
3 |
+from django.db import migrations, models |
|
4 |
+ |
|
5 |
+ |
|
6 |
+class Migration(migrations.Migration): |
|
7 |
+ |
|
8 |
+ dependencies = [ |
|
9 |
+ ('account', '0009_auto_20220707_1801'), |
|
10 |
+ ] |
|
11 |
+ |
|
12 |
+ operations = [ |
|
13 |
+ migrations.AddField( |
|
14 |
+ model_name='userinfo', |
|
15 |
+ name='identifty_card_name', |
|
16 |
+ field=models.CharField(blank=True, help_text='身份证姓名', max_length=32, null=True, verbose_name='identifty_card_name'), |
|
17 |
+ ), |
|
18 |
+ migrations.AddField( |
|
19 |
+ model_name='userinfo', |
|
20 |
+ name='identifty_card_number', |
|
21 |
+ field=models.CharField(blank=True, help_text='身份证号码', max_length=32, null=True, verbose_name='identifty_card_number'), |
|
22 |
+ ), |
|
23 |
+ ] |
@@ -40,6 +40,10 @@ class UserInfo(BaseModelMixin): |
||
40 | 40 |
province = models.CharField(_('province'), max_length=255, blank=True, null=True, help_text='用户省份') |
41 | 41 |
city = models.CharField(_('city'), max_length=255, blank=True, null=True, help_text='用户城市') |
42 | 42 |
|
43 |
+ # 身份证 |
|
44 |
+ identifty_card_number = models.CharField(_('identifty_card_number'), max_length=32, blank=True, null=True, help_text='身份证号码') |
|
45 |
+ identifty_card_name = models.CharField(_('identifty_card_name'), max_length=32, blank=True, null=True, help_text='身份证姓名') |
|
46 |
+ |
|
43 | 47 |
user_status = models.IntegerField(_('user_status'), choices=USER_STATUS, default=UNVERIFIED, help_text='用户状态') |
44 | 48 |
|
45 | 49 |
class Meta: |
@@ -2,13 +2,17 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+from django.db.models import Q |
|
5 | 6 |
from django_response import response |
6 | 7 |
from TimeConvert import TimeConvert as tc |
7 | 8 |
|
8 |
-from equipment.models import AntigenMeasureLogInfo, IsolationPointUserInfo |
|
9 |
+from account.models import UserInfo |
|
10 |
+from equipment.models import AntigenMeasureLogInfo, IsolationPointUserInfo, IsolationPointInfo |
|
11 |
+from utils.error.errno_utils import IsolationPointStatusCode |
|
9 | 12 |
|
10 | 13 |
|
11 | 14 |
def upload_antigen(request): |
15 |
+ unionid = request.POST.get('unionid', '') |
|
12 | 16 |
macid = request.POST.get('macid', '') |
13 | 17 |
user_name = request.POST.get('user_name', '') |
14 | 18 |
phone = request.POST.get('phone', 1) |
@@ -18,7 +22,7 @@ def upload_antigen(request): |
||
18 | 22 |
detect_at = tc.string_to_datetime(detect_at, format='%Y-%m-%d %H:%M:%S') |
19 | 23 |
|
20 | 24 |
try: |
21 |
- user = IsolationPointUserInfo.objects.get(fields__icontains=phone, member_id='', status=True) |
|
25 |
+ user = IsolationPointUserInfo.objects.get(Q(fields__icontains=phone, member_id='') | Q(unionid=unionid), status=True) |
|
22 | 26 |
user.detect_at = detect_at |
23 | 27 |
user.antigen_result = result |
24 | 28 |
user.save() |
@@ -26,6 +30,7 @@ def upload_antigen(request): |
||
26 | 30 |
user = None |
27 | 31 |
|
28 | 32 |
AntigenMeasureLogInfo.objects.create( |
33 |
+ unionid=unionid, |
|
29 | 34 |
point_id=user.point_id if user else '', |
30 | 35 |
user_id=user.user_id if user else '', |
31 | 36 |
macid=macid, |
@@ -36,3 +41,38 @@ def upload_antigen(request): |
||
36 | 41 |
) |
37 | 42 |
|
38 | 43 |
return response(200, '', 'Antigen Upload Success', '抗原检测上传成功') |
44 |
+ |
|
45 |
+ |
|
46 |
+def get_antigen_screen_data(point_id): |
|
47 |
+ try: |
|
48 |
+ point = IsolationPointInfo.objects.get(point_id=point_id, status=True) |
|
49 |
+ except IsolationPointInfo.DoesNotExist: |
|
50 |
+ return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND) |
|
51 |
+ |
|
52 |
+ ipuis = IsolationPointUserInfo.objects.filter(point_id=point_id, status=True).order_by('-detect_at') |
|
53 |
+ ipuis = [ipui.antigen_screen_data for ipui in ipuis] |
|
54 |
+ |
|
55 |
+ return ipuis |
|
56 |
+ |
|
57 |
+ |
|
58 |
+def get_antigen_screen_result(request): |
|
59 |
+ point_id = request.POST.get('point_id', '') |
|
60 |
+ |
|
61 |
+ screen_data = get_antigen_screen_data(point_id) |
|
62 |
+ |
|
63 |
+ return response(data=screen_data) |
|
64 |
+ |
|
65 |
+ |
|
66 |
+def userinfo_update(request): |
|
67 |
+ unionid = request.POST.get('unionid', '') |
|
68 |
+ phone = request.POST.get('phone', '') |
|
69 |
+ identifty_card_number = request.POST.get('identifty_card_number', '') |
|
70 |
+ identifty_card_name = request.POST.get('identifty_card_name', '') |
|
71 |
+ |
|
72 |
+ if unionid: |
|
73 |
+ return response(40001, 'Unionid Cannot Be Empty', 'Unionid 不能为空') |
|
74 |
+ |
|
75 |
+ UserInfo.objects.filter(unionid=unionid).update(phone=phone, identifty_card_name=identifty_card_name, identifty_card_number=identifty_card_number) |
|
76 |
+ IsolationPointUserInfo.objects.filter(unionid=unionid).update(phone=phone, name=identifty_card_name) |
|
77 |
+ |
|
78 |
+ return response(200, '', 'UserInfo Update Success', '用户个人信息更新成功') |
@@ -87,6 +87,7 @@ urlpatterns += [ |
||
87 | 87 |
url(r'^screen/info$', screen_views.screen_info, name='screen_info'), |
88 | 88 |
|
89 | 89 |
url(r'^screen/eqpt/result$', eqpt_views.screen_eqpt_result, name='screen_eqpt_result'), |
90 |
+ url(r'^screen/antigen/reslut$', antigen_views.get_antigen_screen_result, name='get_antigen_screen_result'), |
|
90 | 91 |
] |
91 | 92 |
|
92 | 93 |
# AEP |
@@ -99,6 +100,10 @@ urlpatterns += [ |
||
99 | 100 |
url(r'^upload/antihelion$', antigen_views.upload_antigen, name='antigen_upload'), |
100 | 101 |
] |
101 | 102 |
|
103 |
+# External API |
|
104 |
+urlpatterns += [ |
|
105 |
+ url(r'^external/userinfo/update$', antigen_views.userinfo_update, name='external_userinfo_update'), |
|
106 |
+] |
|
102 | 107 |
|
103 | 108 |
# Household |
104 | 109 |
urlpatterns += [ |
@@ -0,0 +1,59 @@ |
||
1 |
+# Generated by Django 3.2.6 on 2022-12-26 04:56 |
|
2 |
+ |
|
3 |
+from django.db import migrations, models |
|
4 |
+import jsonfield.fields |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class Migration(migrations.Migration): |
|
8 |
+ |
|
9 |
+ dependencies = [ |
|
10 |
+ ('equipment', '0032_auto_20221202_1415'), |
|
11 |
+ ] |
|
12 |
+ |
|
13 |
+ operations = [ |
|
14 |
+ migrations.AddField( |
|
15 |
+ model_name='antigenmeasureloginfo', |
|
16 |
+ name='unionid', |
|
17 |
+ field=models.CharField(blank=True, help_text='微信 Unionid', max_length=32, null=True, verbose_name='user_id'), |
|
18 |
+ ), |
|
19 |
+ migrations.AddField( |
|
20 |
+ model_name='isolationpointuserinfo', |
|
21 |
+ name='age', |
|
22 |
+ field=models.CharField(blank=True, db_index=True, help_text='身份证年龄', max_length=32, null=True, verbose_name='age'), |
|
23 |
+ ), |
|
24 |
+ migrations.AddField( |
|
25 |
+ model_name='isolationpointuserinfo', |
|
26 |
+ name='antigen_observed_days', |
|
27 |
+ field=models.IntegerField(default=0, help_text='已测抗原天数', verbose_name='observed_days'), |
|
28 |
+ ), |
|
29 |
+ migrations.AddField( |
|
30 |
+ model_name='isolationpointuserinfo', |
|
31 |
+ name='antigen_observed_ymds', |
|
32 |
+ field=jsonfield.fields.JSONField(blank=True, default=[], help_text='已测抗原日期', null=True, verbose_name='antigen_observed_ymds'), |
|
33 |
+ ), |
|
34 |
+ migrations.AddField( |
|
35 |
+ model_name='isolationpointuserinfo', |
|
36 |
+ name='name', |
|
37 |
+ field=models.CharField(blank=True, db_index=True, help_text='身份证姓名', max_length=32, null=True, verbose_name='name'), |
|
38 |
+ ), |
|
39 |
+ migrations.AddField( |
|
40 |
+ model_name='isolationpointuserinfo', |
|
41 |
+ name='phone', |
|
42 |
+ field=models.CharField(blank=True, db_index=True, help_text='手机号', max_length=32, null=True, verbose_name='phone'), |
|
43 |
+ ), |
|
44 |
+ migrations.AddField( |
|
45 |
+ model_name='isolationpointuserinfo', |
|
46 |
+ name='sex', |
|
47 |
+ field=models.IntegerField(choices=[(0, '未知'), (1, '男'), (2, '女')], default=0, help_text='身份证性别', verbose_name='sex'), |
|
48 |
+ ), |
|
49 |
+ migrations.AddField( |
|
50 |
+ model_name='isolationpointuserinfo', |
|
51 |
+ name='unionid', |
|
52 |
+ field=models.CharField(blank=True, help_text='微信 Unionid', max_length=32, null=True, verbose_name='unionid'), |
|
53 |
+ ), |
|
54 |
+ migrations.AlterField( |
|
55 |
+ model_name='isolationpointuserinfo', |
|
56 |
+ name='antigen_result', |
|
57 |
+ field=models.IntegerField(choices=[(0, '阴性'), (1, '阳性'), (2, '无效结果')], default=2, help_text='抗原检测结果', verbose_name='antigen_result'), |
|
58 |
+ ), |
|
59 |
+ ] |
@@ -163,14 +163,21 @@ class IsolationPointUserInfo(BaseModelMixin): |
||
163 | 163 |
ANTIGEN_RESULT_TYPE = ( |
164 | 164 |
(NEGATIVE, '阴性'), |
165 | 165 |
(POSITIVE, '阳性'), |
166 |
- (UNKNOWN, '未知'), |
|
166 |
+ (UNKNOWN, '无效结果'), |
|
167 | 167 |
) |
168 | 168 |
|
169 | 169 |
point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True) |
170 | 170 |
|
171 |
+ unionid = models.CharField(_('unionid'), max_length=32, blank=True, null=True, help_text='微信 Unionid') |
|
171 | 172 |
user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户唯一标识', db_index=True) |
172 | 173 |
member_id = models.CharField(_('member_id'), max_length=32, blank=True, null=True, help_text='家庭成员唯一标识', db_index=True) |
173 | 174 |
|
175 |
+ # 身份证上信息,以及电话 |
|
176 |
+ name = models.CharField(_('name'), max_length=32, blank=True, null=True, help_text='身份证姓名', db_index=True) |
|
177 |
+ age = models.CharField(_('age'), max_length=32, blank=True, null=True, help_text='身份证年龄', db_index=True) |
|
178 |
+ sex = models.IntegerField(_('sex'), choices=SexModelMixin.SEX_TUPLE, default=SexModelMixin.UNKNOWN, help_text='身份证性别') |
|
179 |
+ phone = models.CharField(_('phone'), max_length=32, blank=True, null=True, help_text='手机号', db_index=True) |
|
180 |
+ |
|
174 | 181 |
fields = JSONField(_('fields'), default=[], blank=True, null=True, help_text='字段信息') |
175 | 182 |
|
176 | 183 |
observed_ymds = JSONField(_('observed_ymds'), default=[], blank=True, null=True, help_text='已测温日期') |
@@ -188,6 +195,8 @@ class IsolationPointUserInfo(BaseModelMixin): |
||
188 | 195 |
|
189 | 196 |
antigen_result = models.IntegerField(_('antigen_result'), choices=ANTIGEN_RESULT_TYPE, default=UNKNOWN, help_text='抗原检测结果') |
190 | 197 |
detect_at = models.DateTimeField(_('detect_at'), blank=True, null=True, help_text='检测时间') |
198 |
+ antigen_observed_ymds = JSONField(_('antigen_observed_ymds'), default=[], blank=True, null=True, help_text='已测抗原日期') |
|
199 |
+ antigen_observed_days = models.IntegerField(_('observed_days'), default=0, help_text='已测抗原天数') |
|
191 | 200 |
|
192 | 201 |
# 身体状态 |
193 | 202 |
dry_cough_status = models.BooleanField(_(u'dry_cough_status'), default=False, help_text='是否干咳') |
@@ -234,12 +243,12 @@ class IsolationPointUserInfo(BaseModelMixin): |
||
234 | 243 |
def get_antigen_result(self): |
235 | 244 |
today = datetime.date.today() |
236 | 245 |
if not self.detect_at: |
237 |
- return '-' |
|
246 |
+ return u'今日未检测' |
|
238 | 247 |
|
239 | 248 |
if today.day == self.detect_at.day and today.month == self.detect_at.month and today.year == self.detect_at.year: |
240 |
- return '-' if self.antigen_result == 2 else self.get_antigen_result_display() |
|
249 |
+ return self.get_antigen_result_display() |
|
241 | 250 |
else: |
242 |
- return '-' |
|
251 |
+ return u'今日未检测' |
|
243 | 252 |
|
244 | 253 |
@property |
245 | 254 |
def data(self): |
@@ -290,6 +299,19 @@ class IsolationPointUserInfo(BaseModelMixin): |
||
290 | 299 |
'antigen_result': self.get_antigen_result, |
291 | 300 |
'detect_at': tc.local_string(utc_dt=self.detect_at, format='%m-%d %H:%M') if self.detect_at else '', |
292 | 301 |
} |
302 |
+ |
|
303 |
+ @property |
|
304 |
+ def antigen_screen_data(self): |
|
305 |
+ return { |
|
306 |
+ 'point_id': self.point_id, |
|
307 |
+ 'user_id': self.user_id, |
|
308 |
+ 'observed_days': self.antigen_observed_days, |
|
309 |
+ 'last_report_time': tc.local_string(utc_dt=self.detect_at, format='%m-%d %H:%M') if self.detect_at else '', |
|
310 |
+ 'remark': self.remark or '', |
|
311 |
+ 'name': self.name, |
|
312 |
+ 'phone': self.phone, |
|
313 |
+ 'antigen_result': self.get_antigen_result, |
|
314 |
+ } |
|
293 | 315 |
|
294 | 316 |
@property |
295 | 317 |
def userdata(self): |
@@ -504,6 +526,7 @@ class AntigenMeasureLogInfo(BaseModelMixin): |
||
504 | 526 |
point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True) |
505 | 527 |
|
506 | 528 |
user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户唯一标识') |
529 |
+ unionid = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='微信 Unionid') |
|
507 | 530 |
|
508 | 531 |
macid = models.CharField(_('macid'), max_length=32, blank=True, null=True, help_text='设备号') |
509 | 532 |
phone = models.CharField(_('phone'), max_length=11, blank=True, null=True, help_text='用户手机号') |